//
//  TiltIndicator.m
//  LegoClient
//
//  Created by Balazs Faludi on 12.01.10.
//  Copyright 2010 Universität Basel. All rights reserved.
//

#import "TiltIndicator.h"


@implementation TiltIndicator

@synthesize pinImageView, backgroundImageView, value;

- (id)initWithCoder:(NSCoder *)coder {
    if (self = [super initWithCoder:coder]) {
        // Initialization code
		value = CGPointMake(0.0f, 0.0f);
		backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"compasssmall.png"]];
		pinImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TiltPin.png"]];
		[self addSubview:backgroundImageView];
		[self addSubview:pinImageView];
		self.backgroundColor = [UIColor clearColor];
		backgroundImageView.backgroundColor = [UIColor clearColor];
		pinImageView.backgroundColor = [UIColor clearColor];
		backgroundImageView.frame = self.bounds;
		pinImageView.frame = CGRectMake(0.0f, 0.0f, 10.0f, 10.0f);
    }
    return self;
}

- (void)setValue:(CGPoint)newValue {
	value = newValue;
	pinImageView.center = CGPointMake((1 + value.x) * self.bounds.size.width * 0.5, (1 + value.y) * self.bounds.size.height * 0.5);
	//[self setNeedsDisplay];
}

//- (void)drawRect:(CGRect)rect {
    /*if(backgroundImage) {
		[backgroundImage drawInRect:self.bounds];
	}
	if (pinImage) {
		[pinImage drawAtPoint:CGPointMake(self.bounds.size.width * 0.5 + value.x * self.bounds.size.width * 0.5 - pinImage.size.width * 0.5,
										  self.bounds.size.height * 0.5 + value.y * self.bounds.size.height * 0.5 - pinImage.size.height * 0.5)];
	}*/
//}


- (void)dealloc {
	[pinImageView release];
	[backgroundImageView release];
    [super dealloc];
}


@end
